<template>
  <el-card>
    <template #header>
      <el-row :gutter="10" style="float: right">
        <el-button @click="updateMethodList" :icon="Edit" type="primary"
          >更 新</el-button
        >
      </el-row>
    </template>
  </el-card>
    <ts-card header="方法列表" style="margin-top: 10px">
      <sc-form-table
        v-model="dataList"
        :addTemplate="addTemplate"
        edit
        placeholder="暂无数据"
      >
        <template #tableContent>
          <el-table-column prop="name" label="方法名" width="200">
            <template #default="scope">
              <span v-if="scope.row.operationType == ''">{{
                scope.row.name
              }}</span>
              <el-input
                v-else
                v-model="scope.row.name"
                placeholder="请输入方法名"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="title" label="描述" width="200">
            <template #default="scope">
              <span v-if="scope.row.operationType == ''">{{
                scope.row.title
              }}</span>
              <el-input
                v-else
                v-model="scope.row.title"
                placeholder="请输入描述"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="saveLog" label="是否保存日志">
            <template #default="scope">
              <el-switch
                v-model="scope.row.saveLog"
                :disabled="scope.row.operationType == ''"
              >
              </el-switch>
            </template>
          </el-table-column>
          <el-table-column prop="repeatSubmitLockSeconds" label="重复提交锁设置秒数">
            <template #default="scope">
              <span v-if="scope.row.operationType == ''">{{
                scope.row.repeatSubmitLockSeconds
              }}</span>
              <el-input-number v-else v-model="scope.row.repeatSubmitLockSeconds"/>
            </template>
          </el-table-column>
        </template>
      </sc-form-table>
    </ts-card>
</template>
  <script setup>
import { ref, defineModel, onMounted, computed, nextTick, inject } from "vue";
import { Plus, Delete, DCaret, Edit } from "@element-plus/icons-vue";
import { ElMessageBox } from "element-plus";
import API from "@/api/model/report.js";
import Sortable from "sortablejs";
const emit = defineEmits(["update"]);
const props = defineProps({
addTemplate: { type: Object, default: {} },
});
const fileName = inject('fileName')
const dataList = defineModel();
const updateMethodList = async()=>{
    let res = await API.updataMethodList.post({fileName:fileName.value,dataList:dataList.value})
    if(res.code == '200'){
        ElNotification.success({ title: '', message: '更新成功！', duration: 2000 });
        emit('update')
    }
}
</script>
  <style lang="less" scoped></style>